import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '编号',
    align:"center",
    dataIndex: 'ph'
   },
   {
    title: '承包商',
    align:"center",
    dataIndex: 'cbs'
   },
   {
    title: '承包地址',
    align:"center",
    dataIndex: 'sbdz'
   },
   {
    title: '电话',
    align:"center",
    dataIndex: 'dh'
   },
   {
    title: '法人代表',
    align:"center",
    dataIndex: 'frdb'
   },
   {
    title: '发包方',
    align:"center",
    dataIndex: 'fbf'
   },
   {
    title: '签订日期',
    align:"center",
    dataIndex: 'qdrq'
   },
   {
    title: '承包金额',
    align:"center",
    dataIndex: 'cbje'
   },
   {
    title: '保证金',
    align:"center",
    dataIndex: 'bzj'
   },
   {
    title: '承包年限',
    align:"center",
    dataIndex: 'cbnx'
   },
   {
    title: '开始日期',
    align:"center",
    dataIndex: 'strq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '结束日期',
    align:"center",
    dataIndex: 'jsrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '合同文件',
    align:"center",
    dataIndex: 'flname',
    slots: { customRender: 'flnameSlot' },
   },
   {
    title: '运营内容',
    align:"center",
    dataIndex: 'yyfw'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'bz'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '承包商',
    field: 'cbs',
    component: 'JInput',
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'ph',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入编号!'},
          ];
     },
  },
  {
    label: '承包商',
    field: 'cbs',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入承包商!'},
          ];
     },
  },
  {
    label: '承包地址',
    field: 'sbdz',
    component: 'Input',
  },
  {
    label: '电话',
    field: 'dh',
    component: 'Input',
  },
  {
    label: '法人代表',
    field: 'frdb',
    component: 'Input',
  },
  {
    label: '发包方',
    field: 'fbf',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入发包方!'},
          ];
     },
  },
  {
    label: '签订日期',
    field: 'qdrq',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入签订日期!'},
          ];
     },
  },
  {
    label: '承包金额',
    field: 'cbje',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入承包金额!'},
          ];
     },
  },
  {
    label: '保证金',
    field: 'bzj',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入保证金!'},
          ];
     },
  },
  {
    label: '承包年限',
    field: 'cbnx',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入承包年限!'},
          ];
     },
  },
  {
    label: '开始日期',
    field: 'strq',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入开始日期!'},
          ];
     },
  },
  {
    label: '结束日期',
    field: 'jsrq',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入结束日期!'},
          ];
     },
  },
  {
    label: '合同文件',
    field: 'flname',
    component: 'JUpload',
    helpMessage: '最多上传5个文件',
    componentProps: {
      maxCount: 5,
      bizPath: 'cbht'
    },
  },
  {
    label: '运营内容',
    field: 'yyfw',
    component: 'Input',
  },
  {
    label: '备注',
    field: 'bz',
    component: 'InputTextArea',//TODO 注意string转换问题
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

//子表列表数据
export const dbCbskbProColumns: BasicColumn[] = [
   {
    title: '流水号',
    align:"center",
    dataIndex: 'lsh'
   },
   {
    title: '合同编号',
    align:"center",
    dataIndex: 'ph'
   },
   {
    title: '承包商',
    align:"center",
    dataIndex: 'cbs'
   },
   {
    title: '收款日期',
    align:"center",
    dataIndex: 'skrq',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '收款金额',
    align:"center",
    dataIndex: 'skjg'
   },
   {
    title: '退保证金',
    align:"center",
    dataIndex: 'tbzj'
   },
   {
    title: '收款地址',
    align:"center",
    dataIndex: 'skdz'
   },
   {
    title: '票据号码',
    align:"center",
    dataIndex: 'pjhm'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'bz'
   },
];
//子表表单数据
export const dbCbskbProFormSchema: FormSchema[] = [
  {
    label: '流水号',
    field: 'lsh',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入流水号!'},
          ];
     },
  },
  {
    label: '合同编号',
    field: 'ph',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入合同编号!'},
          ];
     },
  },
  {
    label: '承包商',
    field: 'cbs',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入承包商!'},
          ];
     },
  },
  {
    label: '收款日期',
    field: 'skrq',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入收款日期!'},
          ];
     },
  },
  {
    label: '收款金额',
    field: 'skjg',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入收款金额!'},
          ];
     },
  },
  {
    label: '退保证金',
    field: 'tbzj',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入退保证金!'},
          ];
     },
  },
  {
    label: '收款地址',
    field: 'skdz',
    component: 'Input',
  },
  {
    label: '票据号码',
    field: 'pjhm',
    component: 'Input',
  },
  {
    label: '备注',
    field: 'bz',
    component: 'InputTextArea',
  },
];
